﻿using System;

namespace Terraria.DataStructures
{
	// Token: 0x02000486 RID: 1158
	public class TileObjectPreviewData
	{
		// Token: 0x170002B1 RID: 689
		// (get) Token: 0x060026F4 RID: 9972 RVA: 0x0001B346 File Offset: 0x00019546
		// (set) Token: 0x060026F5 RID: 9973 RVA: 0x0001B34E File Offset: 0x0001954E
		public bool Active
		{
			get
			{
				return this._active;
			}
			set
			{
				this._active = value;
			}
		}

		// Token: 0x170002B2 RID: 690
		// (get) Token: 0x060026F6 RID: 9974 RVA: 0x0001B357 File Offset: 0x00019557
		// (set) Token: 0x060026F7 RID: 9975 RVA: 0x0001B35F File Offset: 0x0001955F
		public ushort Type
		{
			get
			{
				return this._type;
			}
			set
			{
				this._type = value;
			}
		}

		// Token: 0x170002B3 RID: 691
		// (get) Token: 0x060026F8 RID: 9976 RVA: 0x0001B368 File Offset: 0x00019568
		// (set) Token: 0x060026F9 RID: 9977 RVA: 0x0001B370 File Offset: 0x00019570
		public short Style
		{
			get
			{
				return this._style;
			}
			set
			{
				this._style = value;
			}
		}

		// Token: 0x170002B4 RID: 692
		// (get) Token: 0x060026FA RID: 9978 RVA: 0x0001B379 File Offset: 0x00019579
		// (set) Token: 0x060026FB RID: 9979 RVA: 0x0001B381 File Offset: 0x00019581
		public int Alternate
		{
			get
			{
				return this._alternate;
			}
			set
			{
				this._alternate = value;
			}
		}

		// Token: 0x170002B5 RID: 693
		// (get) Token: 0x060026FC RID: 9980 RVA: 0x0001B38A File Offset: 0x0001958A
		// (set) Token: 0x060026FD RID: 9981 RVA: 0x0001B392 File Offset: 0x00019592
		public int Random
		{
			get
			{
				return this._random;
			}
			set
			{
				this._random = value;
			}
		}

		// Token: 0x170002B6 RID: 694
		// (get) Token: 0x060026FE RID: 9982 RVA: 0x0001B39B File Offset: 0x0001959B
		// (set) Token: 0x060026FF RID: 9983 RVA: 0x004931CC File Offset: 0x004913CC
		public Point16 Size
		{
			get
			{
				return this._size;
			}
			set
			{
				if (value.X <= 0 || value.Y <= 0)
				{
					throw new FormatException("PlacementData.Size was set to a negative value.");
				}
				if (value.X > this._dataSize.X || value.Y > this._dataSize.Y)
				{
					int num = (int)((value.X > this._dataSize.X) ? value.X : this._dataSize.X);
					int num2 = (int)((value.Y > this._dataSize.Y) ? value.Y : this._dataSize.Y);
					int[,] array = new int[num, num2];
					if (this._data != null)
					{
						for (int i = 0; i < (int)this._dataSize.X; i++)
						{
							for (int j = 0; j < (int)this._dataSize.Y; j++)
							{
								array[i, j] = this._data[i, j];
							}
						}
					}
					this._data = array;
					this._dataSize = new Point16(num, num2);
				}
				this._size = value;
			}
		}

		// Token: 0x170002B7 RID: 695
		// (get) Token: 0x06002700 RID: 9984 RVA: 0x0001B3A3 File Offset: 0x000195A3
		// (set) Token: 0x06002701 RID: 9985 RVA: 0x0001B3AB File Offset: 0x000195AB
		public Point16 Coordinates
		{
			get
			{
				return this._coordinates;
			}
			set
			{
				this._coordinates = value;
			}
		}

		// Token: 0x170002B8 RID: 696
		// (get) Token: 0x06002702 RID: 9986 RVA: 0x0001B3B4 File Offset: 0x000195B4
		// (set) Token: 0x06002703 RID: 9987 RVA: 0x0001B3BC File Offset: 0x000195BC
		public Point16 ObjectStart
		{
			get
			{
				return this._objectStart;
			}
			set
			{
				this._objectStart = value;
			}
		}

		// Token: 0x170002B9 RID: 697
		public int this[int x, int y]
		{
			get
			{
				if (x < 0 || y < 0 || x >= (int)this._size.X || y >= (int)this._size.Y)
				{
					throw new IndexOutOfRangeException();
				}
				return this._data[x, y];
			}
			set
			{
				if (x < 0 || y < 0 || x >= (int)this._size.X || y >= (int)this._size.Y)
				{
					throw new IndexOutOfRangeException();
				}
				this._data[x, y] = value;
			}
		}

		// Token: 0x06002706 RID: 9990 RVA: 0x004932E0 File Offset: 0x004914E0
		public void Reset()
		{
			this._active = false;
			this._size = Point16.Zero;
			this._coordinates = Point16.Zero;
			this._objectStart = Point16.Zero;
			this._percentValid = 0f;
			this._type = 0;
			this._style = 0;
			this._alternate = -1;
			this._random = -1;
			if (this._data != null)
			{
				Array.Clear(this._data, 0, (int)(this._dataSize.X * this._dataSize.Y));
			}
		}

		// Token: 0x06002707 RID: 9991 RVA: 0x00493368 File Offset: 0x00491568
		public void CopyFrom(TileObjectPreviewData copy)
		{
			this._type = copy._type;
			this._style = copy._style;
			this._alternate = copy._alternate;
			this._random = copy._random;
			this._active = copy._active;
			this._size = copy._size;
			this._coordinates = copy._coordinates;
			this._objectStart = copy._objectStart;
			this._percentValid = copy._percentValid;
			if (this._data == null)
			{
				this._data = new int[(int)copy._dataSize.X, (int)copy._dataSize.Y];
				this._dataSize = copy._dataSize;
			}
			else
			{
				Array.Clear(this._data, 0, this._data.Length);
			}
			if (this._dataSize.X < copy._dataSize.X || this._dataSize.Y < copy._dataSize.Y)
			{
				int num = (int)((copy._dataSize.X > this._dataSize.X) ? copy._dataSize.X : this._dataSize.X);
				int num2 = (int)((copy._dataSize.Y > this._dataSize.Y) ? copy._dataSize.Y : this._dataSize.Y);
				this._data = new int[num, num2];
				this._dataSize = new Point16(num, num2);
			}
			for (int i = 0; i < (int)copy._dataSize.X; i++)
			{
				for (int j = 0; j < (int)copy._dataSize.Y; j++)
				{
					this._data[i, j] = copy._data[i, j];
				}
			}
		}

		// Token: 0x06002708 RID: 9992 RVA: 0x00493524 File Offset: 0x00491724
		public void AllInvalid()
		{
			for (int i = 0; i < (int)this._size.X; i++)
			{
				for (int j = 0; j < (int)this._size.Y; j++)
				{
					if (this._data[i, j] != 0)
					{
						this._data[i, j] = 2;
					}
				}
			}
		}

		// Token: 0x04004394 RID: 17300
		public const int None = 0;

		// Token: 0x04004395 RID: 17301
		public const int ValidSpot = 1;

		// Token: 0x04004396 RID: 17302
		public const int InvalidSpot = 2;

		// Token: 0x04004397 RID: 17303
		private ushort _type;

		// Token: 0x04004398 RID: 17304
		private short _style;

		// Token: 0x04004399 RID: 17305
		private int _alternate;

		// Token: 0x0400439A RID: 17306
		private int _random;

		// Token: 0x0400439B RID: 17307
		private bool _active;

		// Token: 0x0400439C RID: 17308
		private Point16 _size;

		// Token: 0x0400439D RID: 17309
		private Point16 _coordinates;

		// Token: 0x0400439E RID: 17310
		private Point16 _objectStart;

		// Token: 0x0400439F RID: 17311
		private int[,] _data;

		// Token: 0x040043A0 RID: 17312
		private Point16 _dataSize;

		// Token: 0x040043A1 RID: 17313
		private float _percentValid;

		// Token: 0x040043A2 RID: 17314
		public static TileObjectPreviewData placementCache;

		// Token: 0x040043A3 RID: 17315
		public static TileObjectPreviewData randomCache;
	}
}
